<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace addons\equip\model;

/**
 * 锁仓
 * Class LockUp
 * @package addons\equip\model
 */
class LockUp extends \web\common\model\BaseModel {

    protected function _initialize() {
        $this->tableName = 'lock_up';
    }

    /**
     *  关联分类表列表
     * @param int $pageIndex
     * @param int $pageSize
     * @param string $filter
     * @param string $fields
     * @param string $order
     * @return mixed
     */
    public function getLockUpList($pageIndex = -1, $pageSize = -1, $filter = '', $fields = 'a.*', $order = 'a.id desc') {
        $sql = 'select '.$fields.' from ' . $this->getTableName() .' as a left join tp_member_account as b on b.id=a.user_id ';
        if (!empty($filter))
            $sql .= ' where ' . $filter;
        return $this->getDataListBySQL($sql, $pageIndex, $pageSize, $order);
    }

    /**
     * 获取记录总数
     * @param type $filter
     * @return int
     */
    public function getLockUpTotal($filter = '') {
        $sql = 'select count(*) as c from '.$this->getTableName() .' as a left join tp_member_account as b on b.id=a.user_id  ';
        if (!empty($filter))
            $sql .= 'where ' . $filter;
        $result = $this->query($sql);

        if (count($result) > 0)
            return intval($result[0]['c']);
        else
            return 0;
    }
    

}
